package com.dingding.es.model;

import com.dingding.es.annotation.DocumentId;
import com.dingding.es.annotation.SearchField;
import com.dingding.es.annotation.TargetClass;
import com.dingding.es.constant.DataType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author liugongding
 * @description:
 * @date 2023/4/12 11:53 PM
 */

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@TargetClass
public class User implements Serializable {

    /**
     * 唯一键
     */
    @DocumentId
    private Integer id;

    @SearchField(type = DataType.KEYWORD)
    private String name;

    @SearchField(type = DataType.INTEGER)
    private Integer age;

    //ik_max_word 需要安装分词器
    @SearchField(type = DataType.TEXT)
    private String description;

    public User (Integer id, String name, Integer age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    public static void main(String[] args) throws Exception {
        User u = new User(1,"d",1);
        Class<User> userClass = User.class;
        //TargetClass annotation = userClass.getAnnotation(TargetClass.class);
        //System.out.println(annotation);

        Object o = userClass.getDeclaredFields();
        System.out.println(o);

    }
}
